package cn.dlc.com.config.web;

import cn.dlc.com.config.formatter.MyStringFormatter;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: dlc
 * @Date: 2021/12/28 - 9:44
 * web核心配置
 * 类型转换器、跨域、拦截器、静态资源
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addFormatters(FormatterRegistry registry) {
        // 处理string类型，如果传递过来的是空的字符串，设置为null
        registry.addFormatterForFieldType(String.class, new MyStringFormatter());
    }
}
